//
//  NewsImageViewController.m
//  BosidengIphone
//
//  Created by  on 11-12-30.
//  Copyright (c) 2011年 __MyCompanyName__. All rights reserved.
//

#import "NewsImageViewController.h"
#import "SyncImageView.h"

@implementation NewsImageViewController
@synthesize imageUrls;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [imageUrls release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle
/*
- (void)initImageView:(NSString *)imageUrl frame:(CGRect)frame {
    SyncImageView *imageView = [[SyncImageView alloc] initWithUrl:imageUrl andRequestQueue:requestQueue];
    imageView.frame = frame;
    [scrollView addSubview:imageView];
    [imageView release];
}
*/
- (void)viewDidLoad
{
    [super viewDidLoad];
    //self.dataSource = self;
    /*
    int paddingX = 0, paddingY = 0;
    int x = 0, y = paddingY;
    int w = 320, h = 416;
    if (imageUrls) {
        for (NSString *url in imageUrls) {
            x += paddingX;
            CGRect frame = CGRectMake(x, y, w, h);
            [self initImageView:url frame:frame];
            x += w;
        }
    }
    
    scrollView.contentSize = CGSizeMake(x + paddingX, h + paddingY);
    */
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (NSInteger)imageCount {
    return [imageUrls count];
}

- (UIView *)configureView:(UIView *)page atIndex:(NSInteger)index {
    NSString *url = [imageUrls objectAtIndex:index];
    if (page == nil) {
        page = [[[SyncImageView alloc] init] autorelease];
    }
    [(SyncImageView *)page loadImage:url andRequestQueue:requestQueue];
    return page;
}

- (void)changePageIndex:(NSInteger)index {
    //NSLog(@"jump to page:%d", index);
}

@end
